#include "ThreadEvent.h"

namespace events {

void ThreadEvent::saveToStream(std::ostream &os) const {
	os.write(reinterpret_cast<const char*>(&_threadEvType), sizeof(_threadEvType));
	os.write(reinterpret_cast<const char*>(&_idThread), sizeof(_idThread));
}

void ThreadEvent::readFromStream(std::istream &is) {
	is.read(reinterpret_cast<char*>(&_threadEvType), sizeof(_threadEvType));
	is.read(reinterpret_cast<char*>(&_idThread), sizeof(_idThread));
}

void ThreadEvent::writeDebugInfo(std::ostream &os) const {
	os << "ThreadEvent: type=";
	switch (_threadEvType) {
		case THREAD_EV_CREATE:
			os << "CREATE";
			break;
		case THREAD_EV_FINISH:
			os << "FINISH";
			break;
		case THREAD_EV_TERMINATE:
			os << "TERMINATE";
			break;
		case THREAD_EV_EXIT:
			os << "EXIT";
			break;
	}
	os << ", id=" << _idThread << '\n';
}


}  // end namespace